package com.zdoon.mapper;

import com.zdoon.pojo.Student;
import com.zdoon.pojo.StudentQueryParam;
import org.apache.ibatis.annotations.*;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface StudentMapper {
    List<Student> selectStudentList(StudentQueryParam studentQueryParam);

    void deleteByIds(List<Integer> ids);

    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into student (name, no, gender, phone, id_card, is_college, address, degree, graduation_date, clazz_id,create_time, update_time)" +
            "values (#{name},#{no},#{gender},#{phone},#{idCard},#{isCollege},#{address},#{degree},#{graduationDate},#{clazzId},#{createTime},#{updateTime})")
    void add(Student student);

    @Select("select id, name, no, gender, phone, id_card, is_college, address, degree, graduation_date, clazz_id, create_time, update_time from student where id = #{id}")
    Student getById(Integer id);

    void update(Student student);

    @Update("update student set violation_count = #{count},violation_score = #{score},update_time = #{updateTime} where id = #{id}")
    void updateViolation(Integer id, Short count ,Short score, LocalDateTime updateTime);

    @Select("select violation_count,violation_score from student where id = #{id}")
    Student selectViolation(Integer id);
}
